package calendar.messages;

import calendar.*;
import edu.gmu.middleware.Message;
import edu.gmu.streams.BlockInputStream;
import edu.gmu.streams.BlockOutputStream;
import java.io.IOException;
import java.util.ArrayList;

/* this class represents a calendar event */
public class ListResponse implements Message
{ 
  public ArrayList users;

  public ListResponse()
  {
    this.users = null;
  }


  public void addUser ( User user )
  {
    this.users.add( user );
  }

  public ArrayList getUsers()
  {
    return users;
  }


  public void marshal(BlockOutputStream stream) throws IOException
  {
    stream.writeInt( users.size() );
    for ( int i = 0; i < users.size(); i++ )
    {
      ((User)this.users.get(i)).marshal( stream );
    }
  }

  public void unmarshal(BlockInputStream stream) throws IOException
  {
    int tempSize = stream.readInt();
    this.users = new ArrayList();
    for( int i = 0; i < tempSize; i++){
      User user = new User();
      user.unmarshal(stream);
      this.users.add(user);
    }
  }
}
